/*
-----------------------------------------------------------------------------
This source file is part of DIVA
The project of Engineering Lab, dept. of CSIE, NTNU.

Copyright (c) 2000-2006 The Software Engineering Lab, dept. of CSIE, NTNU.
-----------------------------------------------------------------------------
Filename:    ubvm_sphere.h
Description: This file is a vm that show boolean value in shape of ball.
-----------------------------------------------------------------------------
*/
/*------------------------------------------------------------*/
#ifndef _ubvm_text_H_
#define	_ubvm_text_H_
/*------------------------------------------------------------*/

#include "DIVA_VM.h"
#include "MovableText.h"
#include <string>
#include "xParameterPack.h"

//using namespace Ogre;

typedef struct ascii_pair {
	int position ;
	int mode ; 
} ASCII_PAIR ;
class ubvm_text: public DIVA_VM{
private:
	WOP_Entry* _wop;
	string*    _val ;
	int mode;
	int bg_length ;
	int bg_width ;
	int bg_height ;
	int _margin;
	float length;
	float height;
	float width;
	std::string _attribute_material;
	std::string _assign_material;
	std::string _value_material;
	std::string _background_material;
	std::string _current_material;
	static string materials[];
	unsigned int record_asc_size;
	std::vector<Ogre::SceneNode*> _collect_node;
	std::vector<ASCII_PAIR*> asc_pos;
	void translate_stringToMesh(std::string);
	void set_position();
	void Load_Mesh(char c);
	///for value update 用 清除舊的資料 換上新的資料
	void reset();
	void margin(int);

	float max(float a, float b) {return a > b ? a : b;}

public:
	/// constructor & destructor
	ubvm_text(xParameterPack xpp);
	~ubvm_text();

	/// draw - for animation or not.
	//void draw();
	std::string getVMType() { return std::string("primitive"); }

	// the overriden method of DIVA_VM
	void load_3Dresources();
	void reg_event_entity();
	void set_default_values();
	void init_private_attrs_started(); // no more private attributes
	void init_private_attrs_ended(); // special process for attr vm_radius
	void init_print_name();
	void init_background_size();
	void VMValueUpdated();

	// the overridden method of OgreVM
	void setBodyScale(Ogre::Vector3);
	Ogre::Vector3 getOriginalBodySize();
	Ogre::Vector3 getActualSize();
	bool isBodyScaleWrtSceneNode();
	Ogre::Vector3 getBodyScale();
	
	void setMode(int mode) {this->mode = mode;}
	int getMode() {return this->mode;}

	// 暫時的function - 將integer轉成string
	std::string intToString(int its){
		std::stringstream ss;
		std::string str;

		ss << its;
		str = ss.str();
		ss.str("");

		return str;
	}

};
/*------------------------------------------------------------*/
#endif	//#ifndef _ubvm_sphere_H_
/*------------------------------------------------------------*/